﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace InnvoiceActual.Logica.GestorObject.Factura
{
    public class ConfigFactura : INotifyPropertyChanged, IDataErrorInfo
    {

        #region Property

        private byte _codigoEmpresa; //	tinyint(2) ???
        public byte CodigoEmpresa
        {
            get
            {
                return _codigoEmpresa;
            }
            set
            {
                _codigoEmpresa = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("CodigoEmpresa"));
            }
        }

        private int _codigoTipo;	     //tinyint(3)
        public int CodigoTipo
        {
            get
            {
                return _codigoTipo;
            }
            set
            {
                _codigoTipo = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("CodigoTipo"));
            }
        }

        private string _tipo;         //	varchar(20)
        public string Tipo
        {
            get
            {
                return _tipo;
            }
            set
            {
                _tipo = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Tipo"));
            }
        }

        private int _numfactura;	         //int(8)
        public int NumFactura
        {
            get
            {
                return _numfactura;
            }
            set
            {
                _numfactura = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("NumFactura"));
            }
        }

        private string _descripcion;  //varchar(100)	
        public string Descripcion
        {
            get
            {
                return _descripcion;
            }
            set
            {
                _descripcion = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Descripcion"));
            }
        }

        private string _impresora;    //varchar(200)
        public string Impresora
        {
            get
            {
                return _impresora;
            }
            set
            {
                _impresora = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Impresora"));
            }
        }

        private int _renglones;      //tinyint(3)
        public int Renglones
        {
            get
            {
                return _renglones;
            }
            set
            {
                _renglones = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Renglones"));
            }
        }

        private int _copias;         //tinyint(3)
        public int Copias
        {
            get
            {
                return _copias;
            }
            set
            {
                _copias = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Copias"));
            }
        }

        private byte _nc;             //tinyint(1)
        public byte Nc
        {
            get
            {
                return _nc;
            }
            set
            {
                _nc = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Nc"));
            }
        }

        private byte _nd;             //tinyint(1)
        public byte Nd
        {
            get
            {
                return _nd;
            }
            set
            {
                _nd = value;
                if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Nd"));
            }
        }
        
        public event PropertyChangedEventHandler PropertyChanged;

        public string Error
        {
            get
            {
                return null;
            }
        }
        public string this[string propertyName]
        {
            get
            {
                return IsValid(propertyName);
            }
        }

        #endregion Property

        #region Contructor

        public ConfigFactura()
        {
            _codigoEmpresa = 0;
            _codigoTipo = 0;
            _tipo = "";
            _numfactura = 0;
            _descripcion = "";
            _impresora = "";
            _renglones = 0;
            _copias = 0;
            _nc = 0;
            _nd = 0;
        }


        #endregion Contructor

        #region metodos de validacion

        private string IsValid(string propertyName)
        {
            switch (propertyName)
            {
                //case "CodigoTipo":
                //    if (string.IsNullOrWhiteSpace(CodigoTipo.ToString()))
                //        return "El campo tipo de factura es requerido";
                //    else if (CodigoTipo.ToString().Length > 0)
                //        return "El campo tipo de factura debe " +
                //               "ser mayor distinto de cero";
                //    break;
                //case "tipo":
                //    if (string.IsNullOrWhiteSpace(tipo))
                //        return "El campo Razon Social es requerido";
                //    else if (tipo.Length > 0)
                //        return "El campo tipo Legal debe " +
                //               "contener más de 10 caracteres";
                //    break;
                //case "Impresora":
                //    if (string.IsNullOrWhiteSpace(Impresora))
                //        return "El campo Impresora es requerido";
                //    break;
            }
            return null;
        }


        public bool IsValid()
        {
            return string.IsNullOrEmpty(IsValid("Descripcion"))
                && string.IsNullOrEmpty(IsValid("renglones"));
        }

        #endregion metodos de validacion

        #region metodosAuxiliares



        #endregion metodosAuxiliares

    }
}
